<{include file=$module.'/header.php'}>
<div class="page getcash">
	<header class="bar bar-nav common-bar-nav">
		<a class="icon pull-left fa fa-arrow-left back"></a>
		<h1 class="title">点数充值</h1>
		<a class="pull-right external" href="/<{$routeUrl}>/score_log?tab=1">点数记录</a>
	</header>
	<{include file=$module.'/nav.php'}>
	<div class="content">
		<div class="takeout-title">
			账户余额：<span><{$admin.money}> 元</span>
		</div>
		<ul class="takeout-list">
			<li>
				<div class="takeout-item-left">充值金额</div>
				<div class="takeout-item-right">
					<div class="takeout-item-input">
						<input type="text" placeholder="" id="fee" value="100">
					</div>
					<p class="takeout-rule">最低充值为 10 元, 1元兑换10点</p>
					<{if $admin.money < 10}>
						<a href="#" class="button button-big button-fill button-success disabled">不足 10 元</a>
					<{else}>
						<a href="#" class="button button-big button-fill button-danger">充值</a>
					<{/if}>
				</div>
			</li>

			
		</ul>
	</div>
</div>

<script>
$(function(){
	$('.button-danger').click(function(){
		var $this = $(this);
		if($this.hasClass('disabled')) {
			return false;
		}
		var account = <{$admin.money}>;
		var fee = parseFloat($.trim($('#fee').val()));
		if(isNaN(fee)) {
			$.toast('余额提现有误');
			return false;
		}
		if(fee > account) {
			$.toast('提现余额大于账户可用余额');
			return false;
		}
		if(fee < 100) {
			$.toast('提现余额不能小于 100 元');
			return false;
		}
		// var rule_fee = (fee * 10).toFixed(2);
		// rule_fee = Math.max(rule_fee, account.fee_min);
		// rule_fee = Math.min(rule_fee, account.fee_max);
		// rule_fee = parseFloat(rule_fee);
		// var final_fee = (fee / 100).toFixed(2);
		var final_fee = (fee * 10);
		var tips = "充值 " + fee + " 元, 实际到账 " + final_fee + " 点, 确定充值吗";
		$.confirm(tips, function(){
			if(final_fee <= 0) {
				$.toast('实际到账金额小于0元, 不能进行提现');
				return false;
			}
			$this.addClass('disabled');
			$.post("/<{$routeUrl}>/<{$action}>", {do:'getscore',fee: fee}, function(response){
				// var result = $.parseJSON(data);
				if(response.code == 0) {
					$.toast(response.msg, response.url);
					$this.removeClass('disabled');
				} else {
					$.toast('充值成功', "/<{$routeUrl}>/index");
				}
				return false;
			});
		});
	});
});
</script>

<{include file=$module.'/footer.php'}>